package de.mmis.helferlein.demo;

import java.io.IOException;

import de.mmis.core.base.event.Observable;
import de.mmis.core.base.event.Observer;
import de.mmis.core.publishsubscribe.PublishSubscribe;
import de.mmis.core.publishsubscribe.PublishSubscribeImpl;
import de.mmis.core.publishsubscribe.PublishSubscribe.PublishSubscribeException;
import de.mmis.core.publishsubscribe.filter.Filter;
import de.mmis.helferlein.demo.IntProducer.IntEvent;

/* GenericPublisher arguments:
 --gui
 --object "Consumer" "($java-object de.mmis.applications.simpleExamples.publishsubscribe.SimpleConsumer)"
 --subscribeC "$Int >= 3" de.mmis.applications.simpleExamples.publishsubscribe.IntProducer$IntEvent "(event @EVENT)"
 */
public class SimpleConsumer1 implements Observer<IntEvent> {
	@Override
	public void notify(Observable<? extends IntEvent> sender, IntEvent event) {
		System.out.println("notify/2: " + event + " from " + sender);
	}

	public static void main(String[] args) throws PublishSubscribeException,
			IOException {
		PublishSubscribe ps = PublishSubscribeImpl.getInstance();
		Filter filter = Filter.parse("$Int >= 3");

		Integer id = ps
				.subscribe(IntEvent.class, filter, new SimpleConsumer1());

		System.in.read();

		ps.unsubscribe(id);
	}
}
